package com.dragons.dragonsvf.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author dragons
 * @version 1.0.0
 * @description: 通用返回数据类
 * @date 2025/3/14 10:21
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseDTO<T> {
    int code;
    String msg;
    T data;
    private String fileName; // 新增：文件名（如"对比结果.xlsx"）
    private String fileType; // 新增：文件MIME类型（如"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"）
    

    public ResponseDTO(int code, String msg){
        this(code,msg,null);
    }

    public ResponseDTO(int code, String msg, Object o) {
    }


    public ResponseDTO<T> error(String statusMsg) {
        return this.error(500, statusMsg);
    }

    public ResponseDTO<T> error(int statusCode, String statusMsg) {
        this.code = statusCode;
        this.msg = statusMsg;
        return this;
    }

    public ResponseDTO<T> ok(String statusMsg) {
        return this.ok(200,statusMsg);
    }

    public ResponseDTO<T> ok(int statusCode, String statusMsg) {
        this.code = statusCode;
        this.msg = statusMsg;
        return this;
    }

    public <T> T getData() {
        return (T)data;
    }

    public ResponseDTO setData(T data) {
        this.data = data;
        return this;
    }
}
